package com.sixkey.controller.app;


import com.sixkey.entity.vo.ReSignVo;
import com.sixkey.response.Response;
import com.sixkey.service.ISignService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户签到表 前端控制器
 * </p>
 *
 * @author author
 * @since 2023-10-25
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequestMapping("/api/sign")
@RequiredArgsConstructor
public class ApiSignController {

    private final ISignService signService;

    /**
     * 获取当前用户的所有签到记录
     * @param phone
     * @return
     */
    @GetMapping("/list/{phone}")
    public Response list(@PathVariable("phone") String phone){
        List<ReSignVo> list = signService.getSignRecords(phone);
        return Response.success(list);
    }

    /**
     * 用户会议签到
     * @param phone
     * @return
     */
    @PostMapping("/toSign/{id}/{phone}")
    public Response list(@PathVariable("phone") String phone,
                         @PathVariable("id") int id){
        signService.toSign(phone,id);
        return Response.success();
    }
}
